浏览量 3760
2018/10/17 23:35
<!--
# @Time : 2018/10/17 下午11:39
# @Author : BrownWang
# @Email : 277215243@qq.com
# @File : vue5.html
# @Software: PyCharm -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#app{
color:yellow;
}
</style>
</head>
<body>
<div id="app">
<template v-if="type === 'name'">
<label>用户名:</label>
<input placheholder="输入用户名" key="name-input">
</template>
<template v-else>
<label>邮箱:</label>
<input placheholder="输入邮箱" key="mail-input">
</template>
<button @click="handleToggleClick">切换输入类型</button>
</div>
<script src="/static/js/vue.min.js"></script>
<script>
var app=new Vue({
el:'#app',
data:{
type :'name'
},
methods:{
handleToggleClick:function () {
this.type = this.type === 'name' ? 'mail' :'name';
}
}
})
</script>
</body>
</html>
上一篇 搜索 下一篇